/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.fpt.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author TuanAnh
 */
@Entity
@Table(name = "RomType")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RomType.findAll", query = "SELECT r FROM RomType r"),
    @NamedQuery(name = "RomType.findByRoomType", query = "SELECT r FROM RomType r WHERE r.roomType = :roomType"),
    @NamedQuery(name = "RomType.findByPrice", query = "SELECT r FROM RomType r WHERE r.price = :price"),
    @NamedQuery(name = "RomType.findByNumber", query = "SELECT r FROM RomType r WHERE r.number = :number")})
public class RomType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "roomType")
    private String roomType;
    @Column(name = "price")
    private Integer price;
    @Column(name = "number")
    private Integer number;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "roomType")
    private Collection<Room> roomCollection;

    public RomType() {
    }

    public RomType(String roomType) {
        this.roomType = roomType;
    }

    public String getRoomType() {
        return roomType;
    }

    public void setRoomType(String roomType) {
        this.roomType = roomType;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }

    @XmlTransient
    public Collection<Room> getRoomCollection() {
        return roomCollection;
    }

    public void setRoomCollection(Collection<Room> roomCollection) {
        this.roomCollection = roomCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (roomType != null ? roomType.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RomType)) {
            return false;
        }
        RomType other = (RomType) object;
        if ((this.roomType == null && other.roomType != null) || (this.roomType != null && !this.roomType.equals(other.roomType))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.fpt.entity.RomType[ roomType=" + roomType + " ]";
    }
    
}
